﻿<UserControl x:Class="Rating"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:my="clr-namespace:Tools.Metanol"
             mc:Ignorable="d" 
             Height="auto" Width="auto"
             IsTabStop="True" Focusable="True" xmlns:Tools.Metanol.My.Resources="clr-namespace:Tools.Metanol.My.Resources"
             >
    <UserControl.Resources>
        <Style TargetType="{x:Type ToggleButton}" x:Key="bbase">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="Yellow" />
            <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=ActualHeight}"/>
            <Setter Property="Padding" Value="0" />
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="Focusable" Value="False"/>
        </Style>
        <Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource bbase}" x:Key="star">
            <Setter Property="Content" Value="{x:Static Tools.Metanol.My.Resources:Resources.rating_StarActive}"/>
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="False">
                    <Setter Property="Content" Value="{x:Static Tools.Metanol.My.Resources:Resources.rating_StarInactive}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <UserControl.FocusVisualStyle>
        <Style TargetType="Control">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Margin="-2" StrokeThickness="1" Stroke="Red" StrokeDashArray="1 2"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.FocusVisualStyle>
    <StackPanel Orientation="Horizontal">
        <ToggleButton Name="btnNotRated" Content="{x:Static Tools.Metanol.My.Resources:Resources.rating_NotRated}" Foreground="Blue" FontWeight="Bold" ToolTip="{x:Static Tools.Metanol.My.Resources:Resources.tot_NotRated}">
            <ToggleButton.Style>
                <Style BasedOn="{StaticResource bbase}" TargetType="{x:Type ToggleButton}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="NotRated">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
        <ToggleButton Name="btnRejected" Content="{x:Static Tools.Metanol.My.Resources:Resources.rating_Rejected}" Foreground="Red" ToolTip="{x:Static Tools.Metanol.My.Resources:Resources.tot_Rejected}">
            <ToggleButton.Style>
                <Style BasedOn="{StaticResource bbase}" TargetType="{x:Type ToggleButton}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Rejected">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
        <ToggleButton Name="btn1">
            <ToggleButton.Style>
                <Style BasedOn="{StaticResource star}" TargetType="{x:Type ToggleButton}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star1">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star2">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star3">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star4">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star5">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <Trigger Property="IsChecked" Value="False">
                            <Setter Property="Content" Value="{x:Static Tools.Metanol.My.Resources:Resources.rating_StarInactive}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
        <ToggleButton Name="btn2">
            <ToggleButton.Style>
                <Style BasedOn="{StaticResource star}" TargetType="{x:Type ToggleButton}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star2">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star3">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star4">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star5">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <Trigger Property="IsChecked" Value="False">
                            <Setter Property="Content" Value="{x:Static Tools.Metanol.My.Resources:Resources.rating_StarInactive}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
        <ToggleButton Name="btn3">
            <ToggleButton.Style>
                <Style BasedOn="{StaticResource star}" TargetType="{x:Type ToggleButton}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star3">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star4">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star5">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <Trigger Property="IsChecked" Value="False">
                            <Setter Property="Content" Value="{x:Static Tools.Metanol.My.Resources:Resources.rating_StarInactive}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
        <ToggleButton Name="btn4">
            <ToggleButton.Style>
                <Style BasedOn="{StaticResource star}" TargetType="{x:Type ToggleButton}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star4">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star5">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <Trigger Property="IsChecked" Value="False">
                            <Setter Property="Content" Value="{x:Static Tools.Metanol.My.Resources:Resources.rating_StarInactive}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
        <ToggleButton Name="btn5">
            <ToggleButton.Style>
                <Style BasedOn="{StaticResource star}" TargetType="{x:Type ToggleButton}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:Rating}}, Path=Rating}" Value="Star5">
                            <Setter Property="IsChecked" Value="True"/>
                        </DataTrigger>
                        <Trigger Property="IsChecked" Value="False">
                            <Setter Property="Content" Value="{x:Static Tools.Metanol.My.Resources:Resources.rating_StarInactive}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
    </StackPanel>
</UserControl>
